fix: Do not close wazero module on error (#3758)#3759
fix: Do not close wazero module on error (#3758)#3759kyleconroy merged 1 commit intosqlc-dev:mainfrom edman:main
Conversation
So does wazero return a valid module and an error message in these cases? |
wazero takes care not to leak modules when `InstantiateModule` returns an error. This means that sqlc will call `result.Close` a second time if a non nil module was returned, which causes a segfault.
Ok so.. Your comment made me go back and track more closely what happened. And I found sqlc actually tripped this https://go.dev/doc/faq#nil_error interesting behavior of go with See this example https://go.dev/play/p/66QShXidalq Basically we can't always compare
I'm thinking we can just defer close when |
wazero takes care not to leak modules when `InstantiateModule` returns an error. This means that sqlc will call `result.Close` a second time if a non nil module was returned, which causes a segfault.
Fixes #3758
wazero takes care not to leak modules when
InstantiateModulereturns an error.This means that sqlc will callresult.Closea second time if a non nil module was returned, which causes a segfault.Edit: this statement is wrong. See my comment below for the correct explanation of the segfault.